<template>
  <div class="course_item">
    <el-card>
      <template slot="header">
        <div class="block">
          <el-image :src="courseModel.image">
            <div slot="placeholder" class="image-slot">
              加载中<span class="dot">...</span>
            </div>
            <div slot="error" class="image-slot">
              <el-image src="https://img1.mukewang.com/szimg/607cf0c6092a5af105400304.png">
              </el-image>
            </div>
          </el-image>
          <div style="margin: auto">
            <el-tag type="success">{{ COURSE_STATUS | optionKV(courseModel.status) }}</el-tag>
            <el-tag type="success">{{ COURSE_CHARGE | optionKV(courseModel.charge) }}</el-tag>
            <el-tag type="success">{{ COURSE_LEVEL| optionKV(courseModel.level) }}</el-tag>
          </div>
        </div>
      </template>
      <div>
        <span style="font-size: 20px; color: #2D8CF0">{{ courseModel.name }}</span>
        <div style="font-size: 18px; color: #2D8CF0">
          {{ courseModel.price }}￥
        </div>
        <div>
          {{ courseModel.summary }}
        </div>
        <div>
          <el-tag type="success">{{ courseModel.id }}</el-tag>
          <el-tag type="success">{{ courseModel.time }}</el-tag>
          <el-tag type="success">{{ courseModel.enroll }}人报名</el-tag>
          <el-tag type="success">讲师：{{ courseModel.teacherId }}</el-tag>
        </div>
        <el-button type="text" size="small" @click="goChapter(courseModel)">大章</el-button>
        <el-button type="text" size="small" @click="courseContent(courseModel)">内容</el-button>
        <el-button type="text" size="small" @click="edit(courseModel)">编辑</el-button>
        <el-button type="text" size="small" @click="del(courseModel)">删除</el-button>
      </div>
    </el-card>
  </div>
</template>

<script>
export default {
  name: "CourseItem",
  data() {
    return {
      COURSE_LEVEL: COURSE_LEVEL,
      COURSE_CHARGE: COURSE_CHARGE,
      COURSE_STATUS: COURSE_STATUS,
    }
  },
  props: {
    courseModel: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  methods: {
    edit(row) {
      this.$emit("edit", row);
    },
    del(row) {
      this.$emit("del", row);
    },
    goChapter(row) {
      this.$emit("goChapter", row);
    },
    courseContent(row) {
      this.$emit("courseContent", row);
    }
  }
}
</script>

<style scoped>
.course_item {
  width: 25%;
}

</style>
